package com.wangshouyu.mp.offiaccount.message;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.SerializedName;
import com.wangshouyu.mp.offiaccount.Account;

import java.io.Serializable;
import java.util.Objects;

/**
 * @author 王守钰
 * @date 2020年12月07日 13:37
 * @description 客服基础消息
 */
public abstract class BaseKfMessage implements Serializable {

    /**
     * 回复给用户OpenId
     */
    @SerializedName(value = "touser")
    @JsonProperty(value = "touser")
    @JSONField(name = "touser")
    private String toUser;

    /**
     * 消息类别
     */
    @SerializedName(value = "msgtype")
    @JsonProperty(value = "msgtype")
    @JSONField(name = "msgtype")
    private String msgType;

    /**
     * 客服
     */
    @SerializedName(value = "customservice")
    @JsonProperty(value = "customservice")
    @JSONField(name = "customservice")
    private Account account;

    public String getToUser() {
        return toUser;
    }

    public void setToUser(String toUser) {
        this.toUser = toUser;
    }

    public String getMsgType() {
        return msgType;
    }

    public void setMsgType(String msgType) {
        this.msgType = msgType;
    }

    public Account getAccount() {
        return account;
    }

    public void setAccount(Account account) {
        this.account = account;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        BaseKfMessage that = (BaseKfMessage) o;
        return Objects.equals(toUser, that.toUser) &&
                Objects.equals(msgType, that.msgType) &&
                Objects.equals(account, that.account);
    }

    @Override
    public int hashCode() {
        return Objects.hash(toUser, msgType, account);
    }

    @Override
    public String toString() {
        return "BaseKfMessage{" +
                "toUser='" + toUser + '\'' +
                ", msgType='" + msgType + '\'' +
                ", account=" + account +
                '}';
    }
}
